package com.wlient.springboot_druiddatasource.component.datasource.entity;


import lombok.Data;
import org.apache.commons.lang3.StringUtils;


@Data
public class GpConfiguration extends JdbcConfiguration {

    private String driver = "com.pivotal.jdbc.GreenplumDriver";
    private String extraParams = "";

    public String getJdbc() {
        if (StringUtils.isEmpty(extraParams.trim())) {
            return "jdbc:pivotal:greenplum://HOSTNAME:PORT;DatabaseName=DATABASE"
                    .replace("HOSTNAME", getHost().trim())
                    .replace("PORT", getPort().toString().trim())
                    .replace("DATABASE", getDataBase().trim());
        } else {
            return "jdbc:pivotal:greenplum://HOSTNAME:PORT;DatabaseName=DATABASE?EXTRA_PARAMS"
                    .replace("HOSTNAME", getHost().trim())
                    .replace("PORT", getPort().toString().trim())
                    .replace("DATABASE", getDataBase().trim())
                    .replace("EXTRA_PARAMS", getExtraParams().trim());

        }
    }
}
